package com.itxiuyixiu.tools.swagger;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * 本文件仅作为模板文件，详细内容需要自己赋值过去后配置
 *需要使用@Configuration
 *
 * @author 黄磊
 * @date 2020/4/29
 */
@Primary
public class SwaggerServerConfig implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
        List<SwaggerResource> resources = new ArrayList<>();
        resources.add(swaggerResource("service-a", "/swagger-service-a/v2/api-docs", "2.0"));
        resources.add(swaggerResource("service-b", "/swagger-service-b/v2/api-docs", "2.0"));
        return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}